﻿#region

using iTunesArtworkApp.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace iTunesArtworkApp.BVT
{
    /// <summary>
    ///   Build Verification Tests for the iTunesWrapper Class
    /// </summary>
    [TestClass]
    public class ITunesTester
    {
        /// <summary>
        ///   Tests whether that GetAlbumns() methods returned a non empty list
        ///   This is dependent on whether we have any music albums in our iTunesWrapper app that don't have album 
        ///   art.
        /// </summary>
        [TestMethod]
        public void GetAlbums_Fetches_A_NonEmptyList()
        {
            var iTunesWrapper = new iTunesWrapper();

            var albums = iTunesWrapper.GetAlbums();

            Assert.IsNotNull(albums, "Albums should not be null.");
            Assert.IsTrue(albums.Count > 0, "Albums list should not be empty.");
        }

        /// <summary>
        /// Excercises the UpdateArtwork() method and checks whether Artwork.HasArtwork gets set to true.
        /// </summary>
        [TestMethod]
        public void UpdateArtwork_Sets_HasArtwork_True()
        {
            // act
            var album = new Album
            {
                Artist = "Dead By Sunrise",
                AlbumName = "Out of Ashes",
                Id = 2017
            };
            album.Artwork.DownloadUrl = "http://ecx.images-amazon.com/images/I/41bPIy0sy9L.jpg";

            // arrange
            var iTunesWrapper = new iTunesWrapper();
            iTunesWrapper.UpdateArtwork(ref album);

            // assertd
            Assert.IsTrue(album.Artwork.HasArtwork, "Artwork not updated.");
        }
    } // end class
}